<table class="bordered" >
    <thead>
    <tr>
        <th><div class="new_sale"><a href="?page=products&action=products_addnew">Add New</a></div></th>
    </tr>
    </thead>
    <tr>
    	<?php 
			if(@$errors!=""){
				echo " <td colspan=\"3\"><span class='red'>". @$errors."</span></td>";
			}else{
				if(isset($_REQUEST['msgStatus']))
					echo " <td colspan=\"3\"><span class='red'>". $_REQUEST['msgStatus'].@$_REQUEST['one']."</span></td>";
			 }
			?>
    </tr>
</table>
<div id="dt_example">
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
        <thead>
            <tr>
            	<th>Category</th>
                <th>Code</th>        
                <th>Product</th>
                <th>B_Price</th>
                <th>S_Price</th>
                <th>Available</th>
                <th>Date</th>
                <th>Date Expire</th>        
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
                <?php 
                    $sql = "SELECT p.*, c.cat_name FROM tbl_products p INNER JOIN tbl_category c ON 
				    p.cat_id=c.cat_id";
                    $result = mysql_query($sql);
                     
                    while ( $row = mysql_fetch_array($result)) {
                        
                ?>
                <tr>
                  <td><?php echo $row['cat_name'] ?></td>
                  <td><?php echo $row['pd_code'] ?></td>
                  <td><?php echo $row['pd_name'] ?></td>
                  <td><?php echo $row['buying_price'] ?></td>
                  <td><?php echo $row['selling_price'] ?></td>
                  <td>
                        <?php
                            $sql_avail = "SELECT qty FROM tbl_stocks_available WHERE pd_name='".$row['pd_name']."'";
                            $result_avail = mysql_query($sql_avail); 
                            $row_avail=fetch_assoc($result_avail); 
                            echo $row_avail['qty']; 
                        ?>
                   </td>
                  <td><?php echo $row['date'] ?></td>
                  <td><?php echo $row['expire_date'] ?></td>
                  <td>
                    <a href="index.php?page=products&action=products_addnew&id=<?php echo $row['pd_id'] ?>"><img src="images/edit.png" border="0" alt="Edit"></a> | <a href="verify_products.php?action=delete&id=<?php echo $row['pd_id'] ?>&name=<?php echo $row['pd_name'] ?>" onclick="return confirm('Are you sure want to delete?');"><img src="images/delete.png" border="0" alt="delete"></a>
                  </td>
                </tr>
        <?php 
            }
        ?>
        </tbody>
    </table>
</div>
